package com.ophiux.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ophiux.common.data.tenant.TenantBroker;
import com.ophiux.common.data.tenant.TenantContextHolder;
import com.ophiux.system.mapper.SysLogMapper;
import com.ophiux.system.model.entity.SysLog;
import com.ophiux.system.service.SysLogService;
import org.springframework.stereotype.Service;

/**
 * @desc:
 * @author: hhl
 * @date：2022/7/19 11:52
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper,SysLog> implements SysLogService {


    @Override
    public void saveLog(SysLog sysLog) {
        TenantBroker.applyAs(sysLog::getTenantId, tenantId -> {
            TenantContextHolder.setTenantId(tenantId);
            return baseMapper.insert(sysLog);
        });
    }
}
